package com.ruoyi.wechat.api;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wechat.domain.ScenicSpots;
import com.ruoyi.wechat.service.IScenicSpotsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wechat/spots")
public class WxSpotsController extends BaseController {
    @Autowired
    private IScenicSpotsService scenicSpotsService;
    @Log(title = "微信小程序API-营地周边景点管理",businessType = BusinessType.INSERT)
    @PostMapping("/wxadd")
    public AjaxResult add(@RequestBody ScenicSpots spots){
        return toAjax(scenicSpotsService.insertScenicSpots(spots));
    }
    @GetMapping("/wxlist")
    public AjaxResult list(ScenicSpots spots){
        List<ScenicSpots> list=scenicSpotsService.selectScenicSpotsList(spots);
        return success(list);
    }
    @GetMapping("/wxgetInfo/{scenicId}")
    public AjaxResult getInfo(@PathVariable("scenicId") String scenicId){
        if(scenicId==null){
            return error("周边景点Id不能为空");
        }
        return success(scenicSpotsService.selectScenicSpotsByScenicId(scenicId));

    }
    @DeleteMapping("/delete/{scenicId}")
    public AjaxResult delete(@PathVariable("scenicId") String scenicId){
        if(scenicId==null){
            return  error("周边景点Id不能为空");
        }
        return toAjax(scenicSpotsService.deleteScenicSpotsByScenicId(scenicId));
    }

}
